import { useMemo, useState } from "react";
const fib = (n) => {
  console.log("数字变化");
  if (n < 3) {
    return 1;
  } else {
    return fib(n - 1) + fib(n - 2);
  }
};
const MyMeno = () => {
  const [count1, setCount1] = useState(0);
  const [count2, setCount2] = useState(0);

  const result = useMemo(() => {
    return fib(count1);
  }, [count1]);
  // console.log("渲染");
  return (
    <div className="list">
      useMemo的使用————{result}
      <button
        onClick={() => {
          setCount1(count1 + 1);
        }}
      >
        count1++{count1}
      </button>
      <button
        onClick={() => {
          setCount2(count2 + 1);
        }}
      >
        count2++{count2}
      </button>
    </div>
  );
};
export default MyMeno;
